﻿<%@ Page Title="" MasterPageFile="~/Views/Shared/Site.Master"  Language="C#"Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.User.AddUser>" %>
<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	添加会员
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <link href='<%=Url.Content("~/Scripts/UI/blitzer/jquery-ui-1.8.custom.css") %>' rel="stylesheet" type="text/css" />
    <script src='<%=Url.Content("~/Scripts/jquery-ui-1.8.custom.min.js") %>' type="text/javascript"></script>
    <script src='<%=Url.Content("~/Scripts/jquery.validate.errormsg.js") %>' type="text/javascript"></script>
    <script src='<%=Url.Content("~/Scripts/jquery.metadata.js") %>' type="text/javascript"></script>
    <script type="text/javascript">
     var url = '<%=Url.Action("PlayTypeOption", new { id="",act=Request["act"],cont=Request["cont"],returnurl=Request["returnurl"],Model.Uid})%>';
        function ddlChage(o) {
            document.location.href = url + '&id=' + o.value;
        }
        $(document).ready(function () {

        $("#adduserform").validate();
            var div = $('.div_AddChildConfig');
            div.hide();
            var str = null;
            $("#optionform").validate();
            $("#optionform .table input[validate]").each(function () {
                $(this).parent().css("text-align", "left");
            });
            $("input[modelid]").change(function () {
                var item = $(this);
                var modelid = item.attr("modelid");
                str = item.attr("cktype");
                var cktype = null;
                if (str != undefined) {
                    cktype = eval("(" + str + ")");
                }
                var num = _ParseDouble(this.value);
                if (num == null || num < 0)
                    return;
                else {
                    $("." + modelid + " :text").each(function () {
                        if (cktype != null) {
                            str = $(this).attr("playtype");
                            var flag = false;
                            for (var i in cktype.play) {
                                var item = cktype.play[i];
                                if (item == str) {
                                    flag = true;
                                    break;

                                }
                            }

                            if ((flag == true && cktype.contain == true) || (cktype.contain == false && flag == false)) {
                                this.value = num;
                            }
                        } else {
                            var tp = _ParseDouble($(this).attr("oldvalue"));
                            str = num.div(100).mul(tp);
                            this.value = str;
                        }
                        $(this).valid();
                    });
                }
            }).keypress(function (e) {
                if (e.keyCode == 13) {
                    e.keyCode = 9;
                    this.blur();
                    return false;
                }
            });

        });
        var flag = false;
        var enableAcc=_ParseBool('<%=Model.EnableAddChildConfig %>');
        function rdo_click(p) {
            var div = $('.div_AddChildConfig');
            if (p == 0) {
                div.hide();
                flag = false;
            } else if(enableAcc) {
                div.show();
                flag = true;
            }
        }
        function btnSubmit_Click() {
//            if (enableAcc) {
//                var AllChildCount = $('#AllChildCount');
//                if (flag && parseInt(AllSurrogateCount.value) > parseInt(AllChildCount.value)) {
//                    alert("所有代理配额不能大于所有下级配额!");
//                    return false;
//                }
//            }
            return confirm('确定提交吗？');
        }

    </script>

    <style type="text/css">
    .ui-widget-header {
    background: none;
    border: none;
    }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.DisableClientValidation(); %>
<% Html.BeginForm(new { id = "adduserform" },null); %>
 <% Html.BeginForm(new { id = "optionform" }, new {lottery=Model.LotteryID }); %>
    <fieldset>
        <legend>添加用户</legend>
        <%=Html.ValidationMessage("Error") %>
        <ul class="editlist">
            <li>
                <label class="label">会员级别：</label>
                <span class="spans">
                    <%= Html.RadioButtonFor(p => p.Type, Code.Models.UserType.Member, new { id = "Type_Member",onclick="rdo_click(0)"})%>
                    <%= UserType.Member.GetName() %>
                    <%= Html.RadioButtonFor(p => p.Type, Code.Models.UserType.Surrogate, new { id = "Type_Surrogate",onclick="rdo_click(1)" })%>
                    <%= UserType.Surrogate.GetName()%>
                </span></li>
            <li>
                <label class="label">用户名：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p => p.LoginName, new { @class = "input_Text", validate = "{required:true,regex:'[0-9a-zA-Z]{4,10}',messages:{required:'*',regex:'格式不正确'}}" })%>
                    <font>必须由数字和字母组成且长度为4-10位</font>
                    <%=Html.ValidationMessageFor(p => p.LoginName)%>
                </span></li>
            <li>
                <label class="label">
                    登录密码：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p=>p.LoginPwd, new { @class = "input_Text",type="password", validate = "{required:true,regex:'.{6,12}',messages:{required:'*',regex:'格式不正确'}}" }) %>
                    <font>密码长度为6-12位</font>
                    <%=Html.ValidationMessageFor(p=>p.LoginPwd) %>
                </span></li>
            <li>
                <label class="label">
                    确认密码：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p => p.ConfirmLoginPwd, new { @class = "input_Text", type = "password", validate = "{required:true,equalTo:'#LoginPwd',messages:{required:'*',equalTo:'两次输入不一至'}}" })%>
                    <font>密码长度为6-12位</font>
                    <%=Html.ValidationMessageFor(p => p.ConfirmLoginPwd)%>
                </span></li>
          <%  if ( Code.BLL.CacheManage.OptionSite[Code.Models.Option_Site_Key.Site_Lottery_UseSiteWinMoney].ToBool(false) == false)
              {%>
            <li>
                <label class="label">奖金(百分比)：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p => p.WinMoneyMargin, new { @class = "input_Text", validate = "{range:[0,100],messages:{range:'0-100之间的数字'}}" })%>%
                    <font>默认:100,跟据您的奖金乘以该比率得出奖金差</font>
                    <%=Html.ValidationMessageFor(p => p.WinMoneyMargin)%>
                </span>
            </li>
              <%} %>
       </ul>
          <div>
           
            <br />
          我的返点详情：
            <table class="table" width="100%">
                <%
                var groupwin = Model.Options.GroupBy(p => new { Name=p.WinMoneyName ,ID=p.Option.WinMoneyModelID});
                var wins = groupwin.Select(p => p.Key).OrderBy(p=>p.ID).ToArray();
                var backMoney = Model.Options.GroupBy(p => new { BackName = p.BackMoneyName,BackID = p.Option.BackMoneyTypeID});
                var moneys = backMoney.Select(p => p.Key).OrderBy(p => p.BackID).ToArray(); %>
                <tr>
                    <th>
                     类型\ 模式
                    </th>
                    <% foreach (var item in wins) %>
                    <% { %>
                    <th colspan='2'>
                   
                        <%=item.Name %>
                    </th>
                    <% } %>
                </tr>
                <% var single = groupwin.First().OrderBy(p => p.Option.BackMoneyTypeID).Select(p => new { p.PlayNames, p.Option.BackMoneyTypeID, p.Option.WinMoneyModelID }); %>
                <% foreach (var pl in moneys)%>
                <% { %>
                <tr>
                    <td>
                        <%=pl.BackName%>
                    </td>
                
                    <% foreach (var win in wins)%>
                    <% { %>
                    <% var i = Array.FindIndex(Model.Options, p => p.Option.BackMoneyTypeID == pl.BackID && p.Option.WinMoneyModelID == win.ID ); %>

                    <% var item = Model.Options[i]; %>
                   
                    <td class='<%=win.ID + "BackMoney"%>' colspan="2">
                        <%if (Model.UseSiteBackMoneyRatio) %>
                        <% { %>
                        <%=item.CurrentBackMoneyRatio%>
                        <% } %>
                        <% else %>
                        <% { %>
                        <%=Html.Encode(item.CurrentBackMoneyRatio)%>
                        
                        <% } %>
                    </td>
                    <% } %>
                </tr>

              <%} %>
            </table>
            <br />
          会员返点设置：
            <br />
             <table class="table" width="100%">
             
                <tr>
                    <th rowspan="2">
                     类型\ 模式
                    </th>
                  
                    <% foreach (var item in wins) %>
                    <% { %>
                    <th colspan='2'>
                    <% var result = Array.FindIndex(Model.Options, p => p.Option.WinMoneyModelID == item.ID); %>
                        <%=item.Name %>
                        <%
                           if (Model.Options[result].Option.WinMoneyState == true)
                           {  %>
                            &nbsp;&nbsp;
                            <%if (Model.Options[result].States &&  Code.BLL.PlayTypeOptionManage.SelectFromOption_SetById())
                              {%>
                                    <%= Html.CheckBoxFor(p => p.Options[result].States, "State")%>
                             <% } %>
                          
                           <%} %>
                        
                    </th>
                    <% } %>
                </tr>
                <tr>
                
                </tr>
                <% foreach (var pl in single)%>
                <% { %>
                <tr>
                    <td>
                        <%=pl.PlayNames%>
                    </td>
                
                    <% foreach (var win in wins)%>
                    <% { %>
                    <% var num = Array.FindIndex(Model.Options, p => p.Option.BackMoneyTypeID == pl.BackMoneyTypeID && p.Option.WinMoneyModelID == win.ID ); %>
                      
                    <% var item = Model.Options[num]; %>
                    
                    <td class='<%=win.ID + "BackMoney"%>' colspan="2">
                        <%=Html.HiddenFor(p => p.Options[num].Option.WinMoneyModelID)%>
                      <%=Html.HiddenFor(p => p.Options[num].Option.BackMoneyTypeID)%>
                        <%if (Model.UseSiteBackMoneyRatio) %>
                        <% { %>
                        <%=item.Option.BackMoneyRatio%>
                        <% } %>
                        <% else %>
                        <% { %>
                        <%=Html.TextBoxFor(p => p.Options[num].Option.BackMoneyRatio, new { @class = "text50", playtype = item.Option.BackMoneyTypeID, oldvalue = item.Option.BackMoneyRatio, validate = string.Format("{{required:true,number:true,min:{0},max:{1},messages:{{required:'*',number:'*',min:'>={0}',max:'<={1}'}}}}", item.Option.MinBackMoneyRatio, item.Option.MaxBackMoneyRatio) })%>
                        <%=Html.ValidationMessageFor(p => p.Options[num].Option.BackMoneyRatio)%>
                        <% } %>
                    </td>
                    <% } %>
                </tr>
              <%} %>
               
            </table>
    </div>
       <div class="div_AddChildConfig">
           <ul class="editlist">
                <li>
                    <label class="label"><font color="red" size='3'>代理配额设置</font></label>
                </li>
                <li>
                    <% 
                       var acc = Model.AllChildCount ?? 0; acc = acc <= 0 ? 0 : acc - 1;
                    %>
                    <label class="label" style=" float:none; margin:0px 15px 0px 15px;">所有下级数量:</label>
                    <%--<%=Html.TextBoxFor(p=>p.AllChildCount, new { title="您当前所乘配额"+(Model.AllChildCount), @class ="input_Text text50", validate = "{range:[0,100000000],messages:{range:'大于等于零的数字'}}" }) %>--%>
                    <input name="AllChildCount" title="您当前所乘配额<%=acc %>" class="input_Text text50" value="<%=acc %>" validate = "{range:[0,100000000],messages:{range:'大于等于零的数字'}}"/>
                </li>
            </ul>
        </div>
       
        <ul class="editlist">
            <li class="btn">
                <input type="submit" <%=ViewData["btnAddDisabled"]!=null&&((bool)ViewData["btnAddDisabled"])?"disabled='disabled'":"" %> value="添加" onclick="return btnSubmit_Click()" />&nbsp;&nbsp;<input type="reset" value="重设" />
            </li>
        </ul>
</fieldset>
<% Html.EndForm(); %>
</asp:Content>